// var swiper = new Swiper('.swiper-container', {
//     pagination: '.swiper-pagination',
//     paginationClickable: true,
//     spaceBetween: 30,
//     centeredSlides: true,
//     autoplay: 3000,
//     autoplayDisableOnInteraction: false,
// });
$('#J_adv').hide();

$(function () {
    var t = Date.parse(new Date()), tt =  0, is_pic = IsPC(), do_main='http://'+domain+'/index.php/';
    console.log(t);
    //关闭
    $("#J_code").click(function () {
        $("#J_adv").slideToggle(500);
        var id = $(this).attr('data-id');
        var url = do_main + 'Home/Api/ad_close';
        ckad(url, id);
    });

    $('.J_ad_ck').click(function () {
        var href_url = $(this).attr('data-url'), id = $(this).attr('data-id');
        var url = do_main + 'Home/Api/ad_ck';
        ckad(url, id);
        if(href_url != '')window.open(href_url);
    });

    setTimeout(function () {
        if(is_pic){
            $('#J_adv').css({width:320, height:'auto'});
        }
        $('#J_adv').css('z-index', 2000).slideToggle(500);
        //var url = do_main + 'Home/Api/ad_uv';
        //ckad(url, ad_id);
    }, 1000);

    function ckad(url, id) {
        tt = Date.parse(new Date());
        // setCookies('adv', '1', 60 * 5);
        $.getJSON(url, {ad_id:id, time: tt - t, url:window.location.href, session_id:session_id}, function(json){
            console.log(data);
        });
    }

    function IsPC() {
        var userAgentInfo = navigator.userAgent;
        var Agents = ["Android", "iPhone",
            "SymbianOS", "Windows Phone",
            "iPad", "iPod"];
        var flag = true;
        for (var v = 0; v < Agents.length; v++) {
            if (userAgentInfo.indexOf(Agents[v]) > 0) {
                flag = false;
                break;
            }
        }
        return flag;
    }
})